<template>
  <ul class="list" :style="cListheight">
    <el-scrollbar style="height:100%" v-if="data.length>0">
      <li
        class="list-item"
        v-for="item in data"
        :key="item.id"
        @click="handClickFun(item)"
      >{{item.title}}</li>
    </el-scrollbar>
  </ul>
</template>

<script>
export default {
  props: {
    data: {
      type: Array,
      default: () => []
    },
    listHeight: {
      type: [String, Number],
      default: 200
    }
  },
  computed: {
    cListheight () {
      return {
        height: this.listHeight + "px"
      };
    }
  },
  methods: {
    handClickFun (item) {
      this.$emit("itemClick", item);
    }
  }
};
</script>

<style lang="less" scoped>
/deep/ .el-scrollbar__wrap {
  overflow-x: hidden !important;
}
.list {
  height: 140px;
  .list-item {
    height: 40px;
    line-height: 40px;
    font-size: 12px;
    color: #303133;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }
}
</style>